package cn.lyh.qinfeng.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.lyh.qinfeng.pojo.Memberinfo;
import cn.lyh.qinfeng.pojo.MemberinfoMapper;

/**
 * @author lyh
 * @version 1.0
 * @date 2020/3/19
 * @Description
 */
@Service
public class BaoMingService {

    @Autowired
    MemberinfoMapper memberinfoMapper;



    public List<Memberinfo> getMebInfo() {
        return null;
    }

    /**
     * 检查职业是否存在
     * @param mebclass 职业分类
     * @return 检查情况
     */
    public int checkMeb(String mebclass) {
        return memberinfoMapper.checkMebClass(mebclass).size();
    }

    /**
     * 报名信息存储
     * @param id QQ号
     * @param nickname 昵称
     * @param meboccupation 职业
     * @param mebclass 职业分类
     * @param tuanid 团编号
     * @return 插入情况
     */
    public int insertMeb(Integer id,String nickname,String meboccupation,String mebclass,Integer tuanid) {
        Memberinfo memberinfo = new Memberinfo();
        memberinfo.setId(id);
        memberinfo.setMeboccupation(meboccupation);
        memberinfo.setNickname(nickname);
        memberinfo.setMebclass(mebclass);
        memberinfo.setTuanid(tuanid);
        return memberinfoMapper.inserteMebInfo(memberinfo);
    }

    /**
     * 获取所有的团员信息
     * @param tuanId 团的编号
     * @return 所有团员信息
     */
    public List<Memberinfo> getAllInfo(Integer tuanId) {
        return memberinfoMapper.getAllInfo(tuanId);
    }

    /**
     * 取消报名业务
     * @param tuanId 团队编号
     * @param userId 团员QQ号
     * @return 受影响的函数
     */
    public int deleteUserInfo(Integer tuanId, Integer userId) {
        return memberinfoMapper.deleteUserInfo(tuanId, userId);
    }

    public int deleteAllUserInfo(Integer tuanid) {
        return memberinfoMapper.deleteAllUserInfo(tuanid);
    }

}
